<!DOCTYPE html>
<#assign dicSelect = JspTaglibs["http://www.casic304.cn/dicSelect"]/>
<#assign f = JspTaglibs["http://www.casic304.cn/f"] />
<html>
<head>
    <meta charset="utf-8">
    <title>报告模板管理信息列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${ctx}/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/iconfont/iconfont.css"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/style/qbdms.css">
    <script type="text/javascript">
        var __ctx = "${ctx}";

    </script>
</head>
<body class="listBody">
<div class="qbdms-list">
    <div class="layui-table-view-body">
    <table id="wQbdReportTemplateTable" lay-filter="wQbdReportTemplateTable"></table>
    </div>
</div>
<!-- 列表头部工具栏 -->
<script type="text/html" id="wQbdReportTemplateHeaderToolsBar">
    <div class="ccpui-enterSel">
        <div class="layui-btn-container">
            <@f.a alias="bgmbgl1_xzan,bgmbgl2_xzan" css="layui-btn layui-btn-sm fillBtn" event="add">
            <span>新增</span>
            </@f.a>
            <@f.a alias="bgmbgl1_scan,bgmbgl2_scan" css="layui-btn layui-btn-sm" event="delete">
            <span>删除</span>
            </@f.a>
        </div>
        <form class="layui-form" action="" lay-filter="wQbdReportTemplateQueryForm" >
            <div class="layui-form-body selch">
                <div class="table-top-filter layui-row">
                        <div class="qbdms-listForm">
                                <label class="layui-form-label">模板名称</label>
                            <div class="layui-input-block">
                                <input type="text" class="layui-input filter-value" name="Q_name_SL" placeholder="请输入"/>
                            </div>
                        </div>
                        <div class="qbdms-listForm">
                            <label class="layui-form-label">开始时间</label>
                            <div class="layui-input-block">
                                <input type="text" class="layui-input filter-value start_time1" name="Q_beginCreateTime_DL"
                                       placeholder="请输入"/>
                            </div>
                        </div>
                        <div class="qbdms-listForm">
                            <label class="layui-form-label">结束时间</label>
                            <div class="layui-input-block">
                                <input type="text" class="layui-input filter-value end_time1" name="Q_endCreateTime_DG"
                                       placeholder="请输入"/>
                            </div>
                        </div>
                </div>
                <div class="selchBtn">
                    <a class="layui-btn layui-btn-sm fillBtn" lay-event="query">
                        <span>查询</span>
                    </a>
                    <div class="layui-btn-group">
                        <button type="button" class="layui-btn layui-btn-sm" lay-event="clears"
                                style="width: 28px;font-size: 12px;padding: 0">
                            <i class="iconfont  data-iconcommon_refresh"></i>
                        </button>
                        <button type="button" class="layui-btn layui-btn-sm screenParent" lay-event="screen"
                                style="width: 28px;font-size: 12px;padding: 0">
                            <i class="iconfont data-iconcommon_downarrow screen"></i>
                        </button>
                    </div>
                </div>
            </div>
        </form>
    </div>

</script>
<!-- 右侧工具栏 -->
<script type="text/html" id="wQbdReportTemplateRightToolsBar">
    <@f.a alias="bgmbgl1_mxan,bgmbgl2_mxan" css="RightBtn" event="particulars">详情</@f.a>
    <@f.a alias="gmbgl1_download,gmbgl2_download" css="RightBtn" event="downLoad">下载报告模板</@f.a>
    {{# if('${currentUserId}'==d.createBy ){}}
        <@f.a alias="bgmbgl1_scan,bgmbgl2_scan" css="RightBtn" event="del">删除</@f.a>
    {{#  } }}

</script>
<script src="${ctx}/qbdmsStatic/public/configFile.js"></script>
<script src="${ctx}/layui/layui.js"></script>
<script>
    //一般直接写在一个js文件中
    layui.config({
        base: serverPath.qbdmsPath + staticPath.qbdmsPath //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index','table', 'form', 'common','publicMethods','jquery','layer','propsHandle'], function () {
        var table = layui.table;
        var form = layui.form;
        var common = layui.common;
        var publicMethods = layui.publicMethods;
        var $ = layui.jquery;
        var layer = layui.layer;
        var propsHandle = layui.propsHandle;
        var defProps = {
                //viewMould: 'form/formDef/view/formDesign/moulds/', // 组件模块 存放文件 *****
                viewMould: 'moulds/', // 组件模块 存放文件 *****
                selectorBtn: '.selectorBtn'
            },
            temQuery = new propsHandle();  // 实例化模板功能部分
        temQuery.initTem({
            selectorBtn: defProps.selectorBtn,
            selectorTemPath: setter.views + defProps.viewMould
        });
        common.tableSort('wQbdReportTemplateTable');

        var tableH=publicMethods.tabHeight();

        //第一个实例
        table.render({
            elem: '#wQbdReportTemplateTable'
            ,height:tableH
            ,url: '${ctx}/qbdms/wQbdReportTemplate/list'
            ,page: publicMethods.pageFun() //开启分页
            ,limit: 20
            ,toolbar: '#wQbdReportTemplateHeaderToolsBar'
            ,method: 'post'
            ,defaultToolbar: ['']
            ,autoSort: false //是否排序
            ,cols: [[ //表头
                {type: 'checkbox', fixed: 'left'}
                ,{field: 'sn', type: 'numbers', title: '序号', fixed: 'left'}
                    , {field: 'createUser', title: '操作人', sort: false, sortname: 'createUser',minWidth: '240'}
                    , {field: 'createTime', title: '操作时间', sort: false, sortname: 'createTime',minWidth: '240'}
                    , {field: 'name', title: '模板名称', sort: false, sortname: 'name',minWidth: '160'}
                ,{
                    fixed: 'right',
                    title: '管理',
                    toolbar: '#wQbdReportTemplateRightToolsBar'
                }
            ]],done:function () {
                common.tableSelectCon('.ccpui-enterSel .layui-form input','a[lay-event=query]','.ccpui-enterSel');
            }
        });

        //list页面初始化展开按钮tips展示（展开按钮类名）
        publicMethods.tipsAuto('.screen')
        //筛选条件初始化（页面表格的Id，是否初始化（true、false））
        common.initScreenTop('wQbdReportTemplateTable',true);

        dateReflash()
        function dateReflash() {
            publicMethods.reflashDate({startName:'.start_time1',endName:'.end_time1'});
            publicMethods.reflashDate({startName:'.start_time2',endName:'.end_time2'});
            publicMethods.reflashDate({startName:'.start_time3',endName:'.end_time3'});
            publicMethods.reflashDate({startName:'.start_time4',endName:'.end_time4'});
            publicMethods.reflashDate({startName:'.start_time5',endName:'.end_time5'});
            publicMethods.reflashDate({startName:'.start_time6',endName:'.end_time6'});
            publicMethods.reflashDate({startName:'.start_time7',endName:'.end_time7'});
            publicMethods.reflashDate({startName:'.start_time8',endName:'.end_time8'});
            publicMethods.reflashDate({startName:'.start_time9',endName:'.end_time9'});
            publicMethods.reflashDate({startName:'.start_time10',endName:'.end_time10'});
            publicMethods.reflashDate({startName:'.start_time11',endName:'.end_time11'});
            publicMethods.reflashDate({startName:'.start_time12',endName:'.end_time12'});
        }

        function reflashQuery(isClear) {
            common.tableConditionRender("wQbdReportTemplateTable","wQbdReportTemplateQueryForm",{where:{}},isClear);
        }

        table.on('toolbar(wQbdReportTemplateTable)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            var data = checkStatus.data;
            var _this = this;
            switch (obj.event) {
                case 'add':
                    window.location.href = "${ctx}/qbdms/wQbdReportTemplate/view/add";
                    break;
                case 'delete':
                    var array = "";
                    for (var i = 0; i < data.length; i++) {
                        array+=data[i].id+",";
                    }
                    delFun(data,array);
                    break;
                case 'export':
                    if (data.length == 0) {
                        layer.confirm(publicMethods.confirmStyle('还没有选择，是否导出全部？'),{title: false,skin: 'confirm-class'}, function (index) {
                            layer.close(index);
                            var url =  '${ctx}/qbdms/wQbdReportTemplate/exportData';
                            $("form[lay-filter='wQbdReportTemplateQueryForm']").find(".filter-value").each(function(i,value) {
                                if(i ==0){
                                    url += "?"+this.name+"="+this.value
                                }else{
                                    url += "&"+this.name+"="+this.value
                                }
                            });
                            window.location.href = url;
                        });
                    } else {
                        layer.confirm(publicMethods.confirmStyle('确定导出吗？'),{title: false,skin: 'confirm-class'}, function (index) {
                            layer.close(index);
                            var ids = [];
                            for (var i = 0; i < data.length; i++) {
                                ids.push(data[i].id);
                            }
                            var url = '${ctx}/qbdms/wQbdReportTemplate/exportData?id=' + ids;
                            window.location.href = url;
                        });
                    }
                    break;
                case "import":
                    common.importInit('wQbdReportTemplateTable',"${ctx}/qbdms/wQbdReportTemplate/importData",false,"");
                    dateReflash();
                    break;
                case "query":
                    reflashQuery(false);
                    dateReflash();
                    break;
                case "screen":
                    common.initScreenTop('wQbdReportTemplateTable');
                    dateReflash();
                    form.render();
                    break;
                case "clears":
                    reflashQuery(true);
                    dateReflash();
                    break;

            };
        });

        table.on('tool(wQbdReportTemplateTable)', function(obj) {
            var data = obj.data, //获得当前行数据
                    layEvent = obj.event; //获得 lay-event 对应的值
            switch(layEvent){
                case "edit":
                    window.location.href = '${ctx}/qbdms/wQbdReportTemplate/view/add?id=' + data.id;
                    break;
                case "particulars":
                    window.location.href = '${ctx}/qbdms/wQbdReportTemplate/view/particulars?id=' + data.id;
                    break;
                case "downLoad":
                    window.location.href = '${ctx}/qbdms/wQbdReportTemplate/downloadDoc?id=' + data.id;
                    break;
                case "del":
                    delFun(data,data.id);
                    break;
            }
        });

        function delFun(data,id) {
            if (data.length === 0) {
                layer.alert(publicMethods.confirmStyle('请先选择一行数据!'),{title: false,skin: 'confirm-class'});
            } else {
                layer.confirm(publicMethods.confirmStyle('确定删除当前数据吗?'),{title: false,skin: 'confirm-class'}, function (index) {
                    layer.close(index);
                    $.ajax({
                        url: "${ctx}/qbdms/wQbdReportTemplate/del",
                        type: "post",
                        data: {id:id},
                        dataType: 'json',
                        success: function (data) {
                            layer.alert(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'});
                            //执行重载
                            reflashQuery(true);
                            dateReflash();
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            layer.alert(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'});
                            //执行重载
                            reflashQuery(true);
                            dateReflash();
                        }
                    })
                })
            }
        }

        window.Initialization = function () {
            dateReflash();
        };
        /*刷新时间控件*/
        dateReflash();
        common.tableSort("wQbdReportTemplateTable",{show:window.Initialization});
    });
</script>
</body>
</html>